/*
    Anti-VM Technique Using CPU Fan Detection
    Author: @5mukx
*/

use std::collections::HashMap;
use wmi::{COMLibrary, WMIConnection, WMIResult, Variant};

fn main() -> WMIResult<()>{

    // Initialize COM lib and wmi

    let com_lib = COMLibrary::new()?;
    let wmi_con = WMIConnection::new(com_lib)?;

    // Execute raw wmi query for win32_fan
    let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT * FROM Win32_Fan")?;
    
    // println!("{:?}", results);

    if results.is_empty(){
        println!("[-] No fan instances found. Likely running in a virtual machine.");
    }else{
        println!("[+] Fan instances found ({}). Likely running on bare metal.", results.len());
    }
    
    Ok(())
}